package com.expert.conrtoller;

import com.expert.annotations.RoleAnnotation;
import com.expert.enums.RoleLevel;
import com.expert.result.Result;
import com.expert.service.ExtractService;
import com.expert.vo.ExtractInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: ExtractController
 * @Author: cxs
 * @Date: 2024/03/25 16:17
 * @Description:
 **/
@RestController
@RequestMapping("/extract")
@Slf4j
public class ExtractController {

    @Autowired
    ExtractService extractService;

    /**
     * 获取项目的抽取条件和回避条件的信息
     * @param id 项目id
     * @return
     */
    @RequestMapping("/getConditionAndAvoid/{id}")
    public Result<ExtractInfoVo> getExtractConditionAndAvoid(@PathVariable("id") Long id){
        log.info("获取抽取条件和回避条件信息，项目id：{}",id);
      ExtractInfoVo extractInfoVo=  this.extractService.getConditionAndAvoid(id);
      return Result.success(extractInfoVo);
    }

    /**
     * 抽取专家信息
     * @param id
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @PostMapping("/extract")
    public Result extractExpert(@RequestParam Long id){
        log.info("抽取专家信息");
        this.extractService.extractExpert(id);
        return Result.success();
    }


}
